using System;
using Oracle.ManagedDataAccess.Client;
using OracleInternal.Common;

namespace OracleInternal.BinXml
{
	internal class ObxmlInstruction
	{
		private static readonly int MaxInstructionDataLen = 10;

		private ObxmlInstructionFormat m_InstructionFormat;

		private ulong[] m_InstructionData = new ulong[MaxInstructionDataLen];

		private ObxmlDecodeState m_DecodeState;

		internal bool InstructionPending;

		private char[] charbuf = new char[100];

		private ObxmlStream DataStream
		{
			get
			{
				if (m_DecodeState != null)
				{
					return m_DecodeState.m_BinXmlStream;
				}
				return null;
			}
		}

		internal ObxmlSectionHeader SectionHeader
		{
			get
			{
				if (m_DecodeState != null)
				{
					return m_DecodeState.SectionHeader;
				}
				return null;
			}
		}

		internal ObxmlDocHeader DocHeader
		{
			get
			{
				if (m_DecodeState != null)
				{
					return m_DecodeState.DocHeader;
				}
				return null;
			}
		}

		internal ObxmlOutputObject RequestOutput => m_DecodeState.m_RequestObject.m_RequestOutput;

		internal ObxmlInstruction(ObxmlDecodeState state)
		{
			ResetObxmlInstruction(state);
		}

		internal void ResetObxmlInstruction(ObxmlDecodeState state)
		{
			if (state != null)
			{
				m_DecodeState = state;
				if (m_DecodeState.m_BinXmlStream == null)
				{
					throw new OracleException(ResourceStringConstants.XML_TYPE_BINARY_INTERNAL_ERROR, string.Empty, string.Empty, ObxmlDecodeResponse.GetErrorMessage(ObxmlErrorTypes.CsxInvalidInputStream));
				}
			}
			InstructionPending = false;
			m_InstructionFormat = null;
			ResetData();
		}

		private void ResetLastInstructionToCurrent()
		{
			m_DecodeState.SetLastInstructionToCurrent(resetCurrent: true, copyCsxPartialBuffer: true);
		}

		internal void ResetData()
		{
			for (int i = 0; i < MaxInstructionDataLen; i++)
			{
				m_InstructionData[i] = 0uL;
			}
		}

		internal ObxmlOpcode.OpcodeIds ReadOpcode()
		{
			m_DecodeState.m_LastInstruction.m_Opcode = m_DecodeState.m_CurrentInstruction.m_Opcode;
			m_DecodeState.m_CurrentInstruction.m_Opcode = DataStream.ReadShortIntFromByte();
			return (ObxmlOpcode.OpcodeIds)m_DecodeState.m_CurrentInstruction.m_Opcode;
		}

		internal bool IsLastTokenAttribute()
		{
			ObxmlNodeState lastNodeState = GetLastNodeState();
			if (lastNodeState.NodeType == NodeTypes.Attribute)
			{
				return lastNodeState.m_ElementToken != null;
			}
			return false;
		}

		internal ObxmlNodeState GetLastNodeState()
		{
			return m_DecodeState.GetLastNodeState();
		}

		internal bool ReadSectionHeader(ObxmlOpcode.OpcodeIds opcode)
		{
			if (opcode != ObxmlOpcode.OpcodeIds.STRTSEC)
			{
				return false;
			}
			SectionHeader.Version = (byte)DataStream.ReadShortIntFromByte();
			if (SectionHeader.Version != ObxmlOpcode.HDR_CSX_VERSION)
			{
				return false;
			}
			SectionHeader.Flags = (byte)DataStream.ReadShortIntFromByte();
			if ((SectionHeader.Flags & 8) > 0)
			{
				byte b = (byte)DataStream.ReadShortIntFromByte();
				SectionHeader.DocId = new byte[b];
				DataStream.ReadAndCopyBytes(SectionHeader.DocId, ObxmlStream.sUseCurrentOffset, b);
			}
			if ((SectionHeader.Flags & 0x10) > 0)
			{
				byte b2 = (byte)DataStream.ReadShortIntFromByte();
				SectionHeader.PathId = new byte[b2];
				DataStream.ReadAndCopyBytes(SectionHeader.PathId, ObxmlStream.sUseCurrentOffset, b2);
				byte b3 = (byte)DataStream.ReadShortIntFromByte();
				byte[] destination = new byte[b3];
				DataStream.ReadAndCopyBytes(destination, ObxmlStream.sUseCurrentOffset, b3);
			}
			if ((SectionHeader.Flags & 4) > 0)
			{
				SectionHeader.Rguid = new byte[ObxmlInstructionFormat.HDR_RGUID_LEN];
				DataStream.ReadAndCopyBytes(SectionHeader.Rguid, ObxmlStream.sUseCurrentOffset, ObxmlInstructionFormat.HDR_RGUID_LEN);
			}
			if ((SectionHeader.Flags & 0x40) > 0)
			{
				SectionHeader.BigEflt = true;
			}
			else
			{
				SectionHeader.BigEflt = false;
			}
			if (ObxmlDecodeContext.m_XMLTypeOpcodeDump && ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, OracleTraceTag.BinXML, OracleTraceClassName.ObxmlInstruction, OracleTraceFuncName.ReadSectionHeader, "(BinXMLOpcodeDump) Binary XML " + (m_DecodeState.IsNotSchemaBased ? "Is NOT Schema Based" : "Is Schema Based"));
			}
			return true;
		}

		internal bool ReadDocHeader(ObxmlOpcode.OpcodeIds opcode)
		{
			if (opcode != ObxmlOpcode.OpcodeIds.DOC)
			{
				return false;
			}
			int num = (int)m_InstructionData[1];
			if ((num & ObxmlInstructionFormat.PROLOG_SPECIFIED) > 0)
			{
				DocHeader.XmlDecl = true;
				if ((num & ObxmlInstructionFormat.VERSION_SPECIFIED) > 0)
				{
					DocHeader.Version = (((num & ObxmlInstructionFormat.VERSION_MASK) > 0) ? "1.1" : "1.0");
				}
				else
				{
					DocHeader.Version = "1.0";
				}
				if ((num & ObxmlInstructionFormat.STANDALONE_SPECIFIED) > 0)
				{
					DocHeader.Standalone = (((num & ObxmlInstructionFormat.STANDALONE_TRUE) > 0) ? "yes" : "no");
				}
				if ((num & ObxmlInstructionFormat.ENCODING_SPECIFIED) > 0)
				{
					ulong length = m_InstructionData[0];
					DocHeader.Encoding = DataStream.ReadUtf8String(length);
				}
			}
			else
			{
				int num2 = 0;
				if ((num2 = (int)m_InstructionData[0]) > 0)
				{
					DataStream.SkipBytes(num2);
				}
			}
			return true;
		}

		internal ObxmlOpcode.OpcodeIds ReadInstructionInfo(bool readNewOpcode = false)
		{
			ObxmlOpcode.OpcodeIds opcodeIds = (ObxmlOpcode.OpcodeIds)m_DecodeState.m_CurrentInstruction.m_Opcode;
			if (readNewOpcode)
			{
				opcodeIds = ReadOpcode();
			}
			if (!m_DecodeState.SectionHeaderFound && opcodeIds != ObxmlOpcode.OpcodeIds.STRTSEC)
			{
				throw new OracleException(ResourceStringConstants.XML_TYPE_BINARY_INTERNAL_ERROR, string.Empty, string.Empty, ObxmlDecodeResponse.GetErrorMessage(ObxmlErrorTypes.RequestInputInvalid));
			}
			if (opcodeIds == ObxmlOpcode.OpcodeIds.None || (opcodeIds != ObxmlOpcode.OpcodeIds.FORMATEXTENSION && (opcodeIds < ObxmlOpcode.OpcodeIds.DATSTR1 || opcodeIds >= ObxmlOpcode.OpcodeIds.OPCODE_NUMBER)))
			{
				throw new OracleException(ResourceStringConstants.XML_TYPE_BINARY_INTERNAL_ERROR, string.Empty, string.Empty, ObxmlDecodeResponse.GetErrorMessage(ObxmlErrorTypes.CsxInvalidInstruction));
			}
			if (opcodeIds == ObxmlOpcode.OpcodeIds.FORMATEXTENSION)
			{
				m_DecodeState.IsExtendedOpcode = true;
				try
				{
					opcodeIds = ReadOpcodeInfo(readNewOpcode: true, m_DecodeState.IsExtendedOpcode);
				}
				catch (Exception ex)
				{
					OracleException.HandleError(OracleTraceLevel.Private, (OracleTraceTag)285212672, OracleTraceClassName.ObxmlInstruction, OracleTraceFuncName.ReadInstructionInfo, ex);
					throw;
				}
				if (opcodeIds >= ObxmlOpcode.OpcodeIds.DATSTR6)
				{
					throw new OracleException(ResourceStringConstants.XML_TYPE_BINARY_INTERNAL_ERROR, string.Empty, string.Empty, ObxmlDecodeResponse.GetErrorMessage(ObxmlErrorTypes.CsxInvalidOpcode));
				}
			}
			else
			{
				m_DecodeState.IsExtendedOpcode = false;
				opcodeIds = ReadOpcodeInfo(readNewOpcode: false, m_DecodeState.IsExtendedOpcode);
			}
			Array.Clear(m_InstructionData, 0, MaxInstructionDataLen);
			for (int i = 0; i < m_InstructionFormat.opnum; i++)
			{
				switch (m_InstructionFormat.oplen[i])
				{
				case 1:
					m_InstructionData[i] = (ulong)DataStream.ReadShortIntFromByte();
					break;
				case 2:
					m_InstructionData[i] = (ulong)DataStream.ReadShortInt();
					break;
				case 4:
					m_InstructionData[i] = (ulong)DataStream.ReadInt4();
					break;
				case 8:
					m_InstructionData[i] = (ulong)DataStream.ReadInt8();
					break;
				}
			}
			if (ObxmlDecodeContext.m_XMLTypeOpcodeDump && ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, OracleTraceTag.BinXML, OracleTraceClassName.ObxmlInstruction, OracleTraceFuncName.ReadInstructionInfo, $"(BinXMLOpcodeDump) *****Current Iteration Opcode value is :{(int)opcodeIds}  {ObxmlInstructionFormat.InstructionFormats[(int)opcodeIds].name}   ******");
				for (int j = 0; j < MaxInstructionDataLen; j++)
				{
					Trace.Write(OracleTraceLevel.Private, OracleTraceTag.BinXML, OracleTraceClassName.ObxmlInstruction, OracleTraceFuncName.ReadInstructionInfo, "(BinXMLOpcodeDump)          " + m_InstructionData[j]);
				}
			}
			return opcodeIds;
		}

		private ObxmlOpcode.OpcodeIds ReadOpcodeInfo(bool readNewOpcode = false, bool IsExtended = false)
		{
			if (readNewOpcode)
			{
				ReadOpcode();
			}
			m_InstructionFormat = (IsExtended ? ObxmlInstructionFormat.ExtendedInstructionFormats[m_DecodeState.m_CurrentInstruction.m_Opcode] : ObxmlInstructionFormat.InstructionFormats[m_DecodeState.m_CurrentInstruction.m_Opcode]);
			return (ObxmlOpcode.OpcodeIds)m_DecodeState.m_CurrentInstruction.m_Opcode;
		}

		private ulong GetDataLen(short opcode)
		{
			ulong result = 0uL;
			if (opcode >= 208 && opcode <= 212)
			{
				return result;
			}
			if (m_InstructionFormat.hasfixeddata)
			{
				result = (ulong)m_InstructionFormat.fixeddatalen;
				m_DecodeState.m_CurrentInstruction.DataType = ObxmlOpcode.dataType[opcode];
			}
			else if (m_InstructionFormat.hasvardata)
			{
				if ((m_InstructionFormat.flags & ObxmlInstructionFormat.DTDLEN) > 0)
				{
					result = m_InstructionData[0];
					m_DecodeState.m_CurrentInstruction.DataType = 1;
				}
				else if ((m_InstructionFormat.flags & ObxmlInstructionFormat.TYPDATA) == 0)
				{
					result = m_InstructionData[0];
					m_DecodeState.m_CurrentInstruction.DataType = 1;
				}
				else
				{
					switch (m_InstructionFormat.oplen[0])
					{
					case 1:
					{
						ObxmlInstructionFormat obj = ObxmlInstructionFormat.InstructionFormats[(uint)m_InstructionData[0]];
						_ = obj.hasfixeddata;
						result = (ulong)obj.fixeddatalen;
						m_DecodeState.m_CurrentInstruction.DataType = ObxmlOpcode.dataType[(short)m_InstructionData[0]];
						break;
					}
					case 2:
						result = m_InstructionData[0] & 0xFFFFFFFFFFFF3FFFuL;
						m_DecodeState.m_CurrentInstruction.DataType = (byte)(((m_InstructionData[0] & 0xC000) == (ulong)ObxmlOpcode.DATL2STRMSK) ? 1 : 2);
						break;
					case 4:
						result = m_InstructionData[0] & 0xFFFFFFFF3FFFFFFFuL;
						m_DecodeState.m_CurrentInstruction.DataType = (byte)(((m_InstructionData[0] & 0xC0000000u) == (ulong)ObxmlOpcode.DATL2STRMSK) ? 1 : 2);
						break;
					case 8:
						result = m_InstructionData[0] & 0x3FFFFFFFFFFFFFFFuL;
						m_DecodeState.m_CurrentInstruction.DataType = (byte)(((m_InstructionData[0] & 0xC000000000000000uL) == (ulong)ObxmlOpcode.DATL2STRMSK) ? 1 : 2);
						break;
					}
				}
			}
			else
			{
				if ((m_InstructionFormat.flags & ObxmlInstructionFormat.TOKENID) == 0)
				{
					result = (ulong)m_InstructionFormat.oplen[0];
					m_DecodeState.m_CurrentInstruction.DataType = 1;
					return result;
				}
				result = 0uL;
				m_DecodeState.m_CurrentInstruction.DataType = 1;
			}
			return result;
		}

		internal static bool OpcodeHasDataPart(ObxmlOpcode.OpcodeIds opcode)
		{
			return (ObxmlInstructionFormat.InstructionFormats[(int)opcode].flags & ObxmlInstructionFormat.TYPDATA) > 0;
		}

		private void SkipBytes(long skipCount)
		{
			DataStream.SkipBytes((int)skipCount);
		}

		internal static bool IsCloseTagPending(ObxmlDecodeState decodeState)
		{
			bool flag = false;
			ObxmlOpcode.OpcodeIds opcode = (ObxmlOpcode.OpcodeIds)decodeState.m_LastInstruction.m_Opcode;
			flag = (((uint)(opcode - 188) <= 9u) ? true : false);
			if (flag && decodeState.m_LastInstruction.m_Opcode != decodeState.m_CurrentInstruction.m_Opcode)
			{
				return true;
			}
			return false;
		}

		internal byte ReadNum1()
		{
			try
			{
				return (byte)DataStream.ReadShortIntFromByte();
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Private, (OracleTraceTag)285212672, OracleTraceClassName.ObxmlInstruction, OracleTraceFuncName.ReadNum1, ex);
				throw;
			}
		}

		internal short ReadNum2()
		{
			try
			{
				return DataStream.ReadShortInt();
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Private, (OracleTraceTag)285212672, OracleTraceClassName.ObxmlInstruction, OracleTraceFuncName.ReadNum2, ex);
				throw;
			}
		}

		internal int ReadNum4()
		{
			try
			{
				return DataStream.ReadInt4();
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Private, (OracleTraceTag)285212672, OracleTraceClassName.ObxmlInstruction, OracleTraceFuncName.ReadNum4, ex);
				throw;
			}
		}

		internal int ReadNum4r()
		{
			byte[] array = null;
			try
			{
				array = DataStream.ReadBytes(4);
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Private, (OracleTraceTag)285212672, OracleTraceClassName.ObxmlInstruction, OracleTraceFuncName.ReadNum4r, ex);
				throw;
			}
			return ((array[3] & 0xFF) << 24) | ((array[2] & 0xFF) << 16) | ((array[1] & 0xFF) << 8) | (array[0] & 0xFF);
		}

		internal long ReadLong8()
		{
			try
			{
				return DataStream.ReadInt8();
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Private, (OracleTraceTag)285212672, OracleTraceClassName.ObxmlInstruction, OracleTraceFuncName.ReadLong8, ex);
				throw;
			}
		}

		internal ObxmlNodeState GetNodeData(ulong tokenId, NodeTypes nodeType, ulong datalen = 0uL)
		{
			TokenTypes defaultTokenTypeForNodeType = ObxmlNodeState.GetDefaultTokenTypeForNodeType(nodeType);
			ObxmlToken token = m_DecodeState.GetToken(tokenId, defaultTokenTypeForNodeType);
			ObxmlNodeState nodeState = m_DecodeState.GetNodeState();
			nodeState.ResetObxmlNodeState(nodeType, token, datalen);
			return nodeState;
		}

		internal long ReadAndWriteFixedData(ObxmlOpcode.OpcodeIds opcode, out long processed)
		{
			if (m_DecodeState.TryAppendingBeginTagClosure(null, checkForInitialNode: false, checkForNewNode: false))
			{
				m_DecodeState.GetLastNodeState().ChildNodesCount++;
			}
			m_DecodeState.GetLastNodeState().PendingDataNode = true;
			ProcessTokenOrTextData(m_DecodeState, initTokenOrDataLength: false, out processed);
			bool num = HandleArrayModeDataBegin(opcode, out processed);
			m_DecodeState.m_CurrentInstruction.m_CsxDataLength = (long)GetDataLen((short)opcode);
			ulong num2 = (ulong)m_DecodeState.m_CurrentInstruction.m_CsxDataLength;
			if (num2 != 0)
			{
				if (num2 > (ulong)m_DecodeState.m_RequestObject.m_CountRemaining)
				{
					num2 = (ulong)m_DecodeState.m_RequestObject.m_CountRemaining;
				}
				if (m_DecodeState.m_RequestObject.m_RequestOutput.OutputType == InputOutputTypes.StringBuilder)
				{
					if (1 == (ObxmlDecodeContext.m_XMLTypeOptimizationLevel & 1))
					{
						m_DecodeState.WriteInputToOutput((int)num2, useReplaceChar: false);
					}
					else
					{
						m_DecodeState.WriteInputToOutput((int)num2);
					}
				}
				else
				{
					string text = DataStream.ReadUtf8String(num2);
					if (1 == (ObxmlDecodeContext.m_XMLTypeOptimizationLevel & 1))
					{
						m_DecodeState.m_CurrentInstruction.m_CsxDataText = text;
					}
					else
					{
						m_DecodeState.m_CurrentInstruction.m_CsxDataText = text.ReplaceXmlChars();
					}
					m_DecodeState.m_CurrentInstruction.m_CsxDataLength = m_DecodeState.m_CurrentInstruction.m_CsxDataText.Length * 2;
					m_DecodeState.GetLastNodeState().PendingDataNode = true;
					processed = m_DecodeState.WriteCsxBytes(initCsxDataLength: true);
				}
			}
			if (num)
			{
				m_DecodeState.SetDecodeState(DecodeStates.ElementEndStart);
				ProcessEndElement(out processed);
			}
			return m_DecodeState.m_RequestObject.m_CountRemaining;
		}

		private char[] DecodeWhitespaces(ObxmlOpcode.OpcodeIds opcode, out int datalen)
		{
			datalen = 0;
			while (opcode == ObxmlOpcode.OpcodeIds.SPACE1 || opcode == ObxmlOpcode.OpcodeIds.SPACE2)
			{
				InstructionPending = true;
				short num;
				short num2;
				switch (opcode)
				{
				case ObxmlOpcode.OpcodeIds.SPACE1:
					num = (short)((short)m_InstructionData[0] & ObxmlOpcode.SPACE1_IDMASK);
					num2 = (short)((short)m_InstructionData[0] & ObxmlOpcode.SPACE_FLAGMASK);
					break;
				case ObxmlOpcode.OpcodeIds.SPACE2:
					num = (short)((short)m_InstructionData[0] & ObxmlOpcode.SPACE2_IDMASK);
					num2 = (short)(((short)m_InstructionData[0] >> 8) & ObxmlOpcode.SPACE_FLAGMASK);
					break;
				default:
					num = 0;
					num2 = 0;
					break;
				}
				int num3 = datalen + num;
				if (charbuf.Length < num3)
				{
					char[] destinationArray = charbuf;
					charbuf = new char[num3];
					Array.Copy(charbuf, 0, destinationArray, 0, datalen);
				}
				char c;
				switch (num2)
				{
				case 96:
					c = '\r';
					break;
				case 128:
					charbuf[datalen++] = '\n';
					c = ' ';
					break;
				case 0:
					c = ' ';
					break;
				case 32:
					c = '\t';
					break;
				case 64:
					c = '\n';
					break;
				default:
					c = '\r';
					break;
				}
				for (int i = datalen; i < num3; i++)
				{
					if (c == '\n')
					{
						charbuf[i++] = '\r';
						num3++;
					}
					charbuf[i] = c;
				}
				datalen = num3;
				opcode = ReadInstructionInfo(readNewOpcode: true);
			}
			return charbuf;
		}

		private void SkipData(ObxmlOpcode.OpcodeIds opcode)
		{
			ulong dataLen = GetDataLen((short)opcode);
			SkipBytes((int)dataLen);
		}

		internal byte[] GetEventChars(ObxmlOpcode.OpcodeIds opcode, out ulong datalen, out string stringValue)
		{
			stringValue = null;
			datalen = GetDataLen((short)opcode);
			if (m_DecodeState.m_CurrentInstruction.DataType == 1)
			{
				stringValue = DataStream.ReadUtf8String(datalen);
			}
			else
			{
				stringValue = ReadEventText(null, opcode);
				datalen = (ulong)stringValue.Length;
			}
			m_DecodeState.CurrentDataOperation = DataOperationTypes.NoData;
			return null;
		}

		internal ObxmlNodeState ReadElementInfo(ObxmlOpcode.OpcodeIds Opcode, bool optimizedOpcode, ref ulong qnameid, out string prefix)
		{
			PrefixInfo prefixInfo = null;
			short num = 0;
			ObxmlNodeState obxmlNodeState = null;
			ulong datalen = GetDataLen((short)Opcode);
			bool flag = false;
			prefix = null;
			byte b;
			if (Opcode >= ObxmlOpcode.OpcodeIds.PRPSTK1F && Opcode <= ObxmlOpcode.OpcodeIds.PRPSTT8F)
			{
				b = (byte)m_InstructionData[1];
			}
			else if (Opcode >= ObxmlOpcode.OpcodeIds.PRPSTK1V && Opcode <= ObxmlOpcode.OpcodeIds.PRPSTT8V)
			{
				b = (byte)m_InstructionData[2];
				flag = true;
				datalen = 0uL;
			}
			else
			{
				b = 0;
			}
			if ((m_InstructionFormat.flags & ObxmlInstructionFormat.KIDNUM) <= 0)
			{
				qnameid = ((flag || optimizedOpcode) ? m_InstructionData[1] : m_InstructionData[0]);
				obxmlNodeState = GetNodeData(qnameid, NodeTypes.Element, datalen);
			}
			if (obxmlNodeState == null || obxmlNodeState.IsAttribute)
			{
				return null;
			}
			if (flag)
			{
				if ((b & ObxmlInstructionFormat.ELSTF_NOTDECTYP) > 0)
				{
					DataStream.ReadInt4();
				}
				if ((b & ObxmlInstructionFormat.ELSTF_PFXID) > 0)
				{
					num = DataStream.ReadShortInt();
					prefixInfo = m_DecodeState.GetPrefixInfo((ulong)num);
					prefix = prefixInfo.Prefix;
					obxmlNodeState.PrefixId = num;
				}
			}
			prefix = obxmlNodeState.SetPrefix(m_DecodeState, prefix);
			return obxmlNodeState;
		}

		internal ObxmlNodeState ReadElementInfo(ObxmlOpcode.OpcodeIds opcode, bool optimizedOpcode, ObxmlNodeState ns = null, bool arrayModeDataBegin = false)
		{
			string prefix = null;
			ulong qnameid = 0uL;
			if (ns == null)
			{
				ns = ReadElementInfo(opcode, optimizedOpcode, ref qnameid, out prefix);
			}
			if (ns != null)
			{
				ns.IsOptimizedOpcode = optimizedOpcode;
				m_DecodeState.PushNodeState(ns);
				long processed = 0L;
				if (ProcessPendingBytesOrTokenData(m_DecodeState, initTokenOrDataLength: false, initCsxDataLength: false, out processed) > 0 && !arrayModeDataBegin && ns.NodeDataLen != 0)
				{
					ulong datalen = 0uL;
					string stringValue = null;
					m_DecodeState.m_CurrentInstruction.m_CsxDataLength = 0L;
					if (GetEventChars(opcode, out datalen, out stringValue) != null)
					{
						throw new OracleException(ResourceStringConstants.XML_TYPE_BINARY_INTERNAL_ERROR, string.Empty, string.Empty, ObxmlDecodeResponse.GetErrorMessage(ObxmlErrorTypes.NotImplemented));
					}
					if (!string.IsNullOrEmpty(stringValue))
					{
						ns.PendingDataNode = true;
						if (1 == (ObxmlDecodeContext.m_XMLTypeOptimizationLevel & 1))
						{
							m_DecodeState.m_CurrentInstruction.m_CsxDataText = stringValue;
						}
						else
						{
							m_DecodeState.m_CurrentInstruction.m_CsxDataText = stringValue.ReplaceXmlChars();
						}
						m_DecodeState.m_CurrentInstruction.m_CsxDataLength = (long)m_DecodeState.m_CurrentInstruction.m_CsxDataText.Length * 2L;
					}
				}
				if (!arrayModeDataBegin)
				{
					ReadAttributes_New();
				}
				m_DecodeState.TryAppendingBeginTagClosure(ns, checkForInitialNode: true, checkForNewNode: true);
				ns.NodeId = m_DecodeState.LastNodeId;
				m_DecodeState.m_CurrentInstruction.AppendElementStartToken(m_DecodeState, ns);
				for (int i = 0; i < m_DecodeState.AttributeList.Count; i++)
				{
					m_DecodeState.m_CurrentInstruction.AppendAttributeToken(m_DecodeState, m_DecodeState.AttributeList[i]);
					m_DecodeState.FreeAttributeInfo(m_DecodeState.AttributeList[i]);
				}
				if (m_DecodeState.AttributeList.Count > 0)
				{
					m_DecodeState.AttributeList.Clear();
				}
			}
			return ns;
		}

		private static long ProcessPendingBytesOrTokenData(ObxmlDecodeState decodeState, bool initTokenOrDataLength, bool initCsxDataLength, out long processed)
		{
			long num = 0L;
			if ((num = ProcessTokenOrTextData(decodeState, initTokenOrDataLength, out processed)) > 0)
			{
				num = ProcessCsxBytes(decodeState, initCsxDataLength, out processed);
			}
			return num;
		}

		private static long ProcessTokenOrTextData(ObxmlDecodeState decodeState, bool initTokenOrDataLength, out long processed)
		{
			processed = decodeState.WriteTokenOrData(initTokenOrDataLength);
			return decodeState.m_RequestObject.m_CountRemaining;
		}

		private static long ProcessCsxBytes(ObxmlDecodeState decodeState, bool initCsxDataLength, out long processed)
		{
			processed = decodeState.WriteCsxBytes(initCsxDataLength);
			return decodeState.m_RequestObject.m_CountRemaining;
		}

		private long ProcessEndElement(out long processed)
		{
			_ = m_DecodeState.m_RequestObject.m_CountRemaining;
			m_DecodeState.SetDecodeState(DecodeStates.ElementEndStart | DecodeStates.ElementEndPending, resetOldMasks: false);
			ObxmlNodeState obxmlNodeState = m_DecodeState.PopNodeState();
			ObxmlToken elementToken = obxmlNodeState.m_ElementToken;
			processed = 0L;
			if (elementToken.IsElementToken)
			{
				m_DecodeState.m_CurrentInstruction.AppendElementEndToken(m_DecodeState, obxmlNodeState);
				processed = m_DecodeState.WriteTokenOrData(initTokenOrDataLength: true);
			}
			if (!obxmlNodeState.IsArrayMode && !obxmlNodeState.IsSequentialMode && obxmlNodeState.ArrayModeCount == 0)
			{
				m_DecodeState.FreeNodeState(obxmlNodeState);
			}
			if (m_DecodeState.m_RequestObject.m_CountRemaining != 0L)
			{
				m_DecodeState.ResetDecodeStateMask(DecodeStates.ElementEndStart | DecodeStates.ElementEndPending);
			}
			return m_DecodeState.m_RequestObject.m_CountRemaining;
		}

		internal bool DecodeInstruction_New()
		{
			ObxmlOpcode.OpcodeIds opcode = (ObxmlOpcode.OpcodeIds)m_DecodeState.m_CurrentInstruction.m_Opcode;
			InstructionPending = true;
			InstructionPending = false;
			bool result = false;
			long processed = 0L;
			if (opcode < ObxmlOpcode.OpcodeIds.DEFNM4L1 && !m_DecodeState.IsExtendedOpcode)
			{
				switch (opcode)
				{
				case ObxmlOpcode.OpcodeIds.DATSTR1:
				case ObxmlOpcode.OpcodeIds.DATSTR2:
				case ObxmlOpcode.OpcodeIds.DATSTR3:
				case ObxmlOpcode.OpcodeIds.DATSTR4:
				case ObxmlOpcode.OpcodeIds.DATSTR5:
				case ObxmlOpcode.OpcodeIds.DATSTR6:
				case ObxmlOpcode.OpcodeIds.DATSTR7:
				case ObxmlOpcode.OpcodeIds.DATSTR8:
				case ObxmlOpcode.OpcodeIds.DATSTR9:
				case ObxmlOpcode.OpcodeIds.DATSTR10:
				case ObxmlOpcode.OpcodeIds.DATSTR11:
				case ObxmlOpcode.OpcodeIds.DATSTR12:
				case ObxmlOpcode.OpcodeIds.DATSTR13:
				case ObxmlOpcode.OpcodeIds.DATSTR14:
				case ObxmlOpcode.OpcodeIds.DATSTR15:
				case ObxmlOpcode.OpcodeIds.DATSTR16:
				case ObxmlOpcode.OpcodeIds.DATSTR17:
				case ObxmlOpcode.OpcodeIds.DATSTR18:
				case ObxmlOpcode.OpcodeIds.DATSTR19:
				case ObxmlOpcode.OpcodeIds.DATSTR20:
				case ObxmlOpcode.OpcodeIds.DATSTR21:
				case ObxmlOpcode.OpcodeIds.DATSTR22:
				case ObxmlOpcode.OpcodeIds.DATSTR23:
				case ObxmlOpcode.OpcodeIds.DATSTR24:
				case ObxmlOpcode.OpcodeIds.DATSTR25:
				case ObxmlOpcode.OpcodeIds.DATSTR26:
				case ObxmlOpcode.OpcodeIds.DATSTR27:
				case ObxmlOpcode.OpcodeIds.DATSTR28:
				case ObxmlOpcode.OpcodeIds.DATSTR29:
				case ObxmlOpcode.OpcodeIds.DATSTR30:
				case ObxmlOpcode.OpcodeIds.DATSTR31:
				case ObxmlOpcode.OpcodeIds.DATSTR32:
				case ObxmlOpcode.OpcodeIds.DATSTR33:
				case ObxmlOpcode.OpcodeIds.DATSTR34:
				case ObxmlOpcode.OpcodeIds.DATSTR35:
				case ObxmlOpcode.OpcodeIds.DATSTR36:
				case ObxmlOpcode.OpcodeIds.DATSTR37:
				case ObxmlOpcode.OpcodeIds.DATSTR38:
				case ObxmlOpcode.OpcodeIds.DATSTR39:
				case ObxmlOpcode.OpcodeIds.DATSTR40:
				case ObxmlOpcode.OpcodeIds.DATSTR41:
				case ObxmlOpcode.OpcodeIds.DATSTR42:
				case ObxmlOpcode.OpcodeIds.DATSTR43:
				case ObxmlOpcode.OpcodeIds.DATSTR44:
				case ObxmlOpcode.OpcodeIds.DATSTR45:
				case ObxmlOpcode.OpcodeIds.DATSTR46:
				case ObxmlOpcode.OpcodeIds.DATSTR47:
				case ObxmlOpcode.OpcodeIds.DATSTR48:
				case ObxmlOpcode.OpcodeIds.DATSTR49:
				case ObxmlOpcode.OpcodeIds.DATSTR50:
				case ObxmlOpcode.OpcodeIds.DATSTR51:
				case ObxmlOpcode.OpcodeIds.DATSTR52:
				case ObxmlOpcode.OpcodeIds.DATSTR53:
				case ObxmlOpcode.OpcodeIds.DATSTR54:
				case ObxmlOpcode.OpcodeIds.DATSTR55:
				case ObxmlOpcode.OpcodeIds.DATSTR56:
				case ObxmlOpcode.OpcodeIds.DATSTR57:
				case ObxmlOpcode.OpcodeIds.DATSTR58:
				case ObxmlOpcode.OpcodeIds.DATSTR59:
				case ObxmlOpcode.OpcodeIds.DATSTR60:
				case ObxmlOpcode.OpcodeIds.DATSTR61:
				case ObxmlOpcode.OpcodeIds.DATSTR62:
				case ObxmlOpcode.OpcodeIds.DATSTR63:
				case ObxmlOpcode.OpcodeIds.DATSTR64:
				case ObxmlOpcode.OpcodeIds.DATBIN1:
				case ObxmlOpcode.OpcodeIds.DATBIN2:
				case ObxmlOpcode.OpcodeIds.DATBIN3:
				case ObxmlOpcode.OpcodeIds.DATBIN4:
				case ObxmlOpcode.OpcodeIds.DATBIN5:
				case ObxmlOpcode.OpcodeIds.DATBIN6:
				case ObxmlOpcode.OpcodeIds.DATBIN7:
				case ObxmlOpcode.OpcodeIds.DATBIN8:
				case ObxmlOpcode.OpcodeIds.DATBIN9:
				case ObxmlOpcode.OpcodeIds.DATBIN10:
				case ObxmlOpcode.OpcodeIds.DATBIN11:
				case ObxmlOpcode.OpcodeIds.DATBIN12:
				case ObxmlOpcode.OpcodeIds.DATBIN13:
				case ObxmlOpcode.OpcodeIds.DATBIN14:
				case ObxmlOpcode.OpcodeIds.DATBIN15:
				case ObxmlOpcode.OpcodeIds.DATBIN16:
				case ObxmlOpcode.OpcodeIds.DATBIN17:
				case ObxmlOpcode.OpcodeIds.DATBIN18:
				case ObxmlOpcode.OpcodeIds.DATBIN19:
				case ObxmlOpcode.OpcodeIds.DATBIN20:
				case ObxmlOpcode.OpcodeIds.DATBIN21:
				case ObxmlOpcode.OpcodeIds.DATBIN22:
				case ObxmlOpcode.OpcodeIds.DATBIN23:
				case ObxmlOpcode.OpcodeIds.DATBIN24:
				case ObxmlOpcode.OpcodeIds.DATBIN25:
				case ObxmlOpcode.OpcodeIds.DATBIN26:
				case ObxmlOpcode.OpcodeIds.DATBIN27:
				case ObxmlOpcode.OpcodeIds.DATBIN28:
				case ObxmlOpcode.OpcodeIds.DATBIN29:
				case ObxmlOpcode.OpcodeIds.DATBIN30:
				case ObxmlOpcode.OpcodeIds.DATBIN31:
				case ObxmlOpcode.OpcodeIds.DATBIN32:
				case ObxmlOpcode.OpcodeIds.DATNM1:
				case ObxmlOpcode.OpcodeIds.DATNM2:
				case ObxmlOpcode.OpcodeIds.DATNM3:
				case ObxmlOpcode.OpcodeIds.DATNM4:
				case ObxmlOpcode.OpcodeIds.DATNM5:
				case ObxmlOpcode.OpcodeIds.DATNM6:
				case ObxmlOpcode.OpcodeIds.DATNM7:
				case ObxmlOpcode.OpcodeIds.DATNM8:
				case ObxmlOpcode.OpcodeIds.DATNM9:
				case ObxmlOpcode.OpcodeIds.DATNM10:
				case ObxmlOpcode.OpcodeIds.DATNM11:
				case ObxmlOpcode.OpcodeIds.DATNM12:
				case ObxmlOpcode.OpcodeIds.DATNM13:
				case ObxmlOpcode.OpcodeIds.DATNM14:
				case ObxmlOpcode.OpcodeIds.DATNM15:
				case ObxmlOpcode.OpcodeIds.DATNM16:
				case ObxmlOpcode.OpcodeIds.DATNM17:
				case ObxmlOpcode.OpcodeIds.DATNM18:
				case ObxmlOpcode.OpcodeIds.DATNM19:
				case ObxmlOpcode.OpcodeIds.DATNM20:
				case ObxmlOpcode.OpcodeIds.DATNM21:
				case ObxmlOpcode.OpcodeIds.DATINT1:
				case ObxmlOpcode.OpcodeIds.DATINT2:
				case ObxmlOpcode.OpcodeIds.DATINT4:
				case ObxmlOpcode.OpcodeIds.DATINT8:
				case ObxmlOpcode.OpcodeIds.DATUINT1:
				case ObxmlOpcode.OpcodeIds.DATUINT2:
				case ObxmlOpcode.OpcodeIds.DATUINT4:
				case ObxmlOpcode.OpcodeIds.DATUINT8:
				case ObxmlOpcode.OpcodeIds.DATFLT4:
				case ObxmlOpcode.OpcodeIds.DATFLT8:
				case ObxmlOpcode.OpcodeIds.DATEPH4:
				case ObxmlOpcode.OpcodeIds.DATEPH8:
				case ObxmlOpcode.OpcodeIds.DATEPZ6:
				case ObxmlOpcode.OpcodeIds.DATEPZ10:
				case ObxmlOpcode.OpcodeIds.DATODT:
				case ObxmlOpcode.OpcodeIds.DATOTS:
				case ObxmlOpcode.OpcodeIds.DATOTSZ:
				case ObxmlOpcode.OpcodeIds.DATBOL:
				case ObxmlOpcode.OpcodeIds.DATQNM:
				case ObxmlOpcode.OpcodeIds.DATENM1:
				case ObxmlOpcode.OpcodeIds.DATENM2:
				case ObxmlOpcode.OpcodeIds.DATAL2:
				case ObxmlOpcode.OpcodeIds.DATAL8:
				case ObxmlOpcode.OpcodeIds.DATEMPT:
					m_DecodeState.CurrentDataOperation = DataOperationTypes.LengthAndData;
					m_DecodeState.ResetDecodeStateMask(DecodeStates.ElementDataStartPartial);
					if (ReadAndWriteFixedData(opcode, out processed) != 0L)
					{
						result = true;
					}
					break;
				case ObxmlOpcode.OpcodeIds.PRTDATA:
				case ObxmlOpcode.OpcodeIds.PRTDATAT:
				{
					ProcessPendingBytesOrTokenData(m_DecodeState, initTokenOrDataLength: true, initCsxDataLength: true, out processed);
					ulong dataLen = GetDataLen((short)opcode);
					if (DataStream.ReadUtf8StringChar((int)dataLen, m_DecodeState.m_CurrentInstruction) == 0)
					{
						m_DecodeState.m_CurrentInstruction.ResetTextOrTokenDataLength((int)dataLen + 1);
						DataStream.ReadUtf8StringChar((int)dataLen, m_DecodeState.m_CurrentInstruction);
					}
					ProcessTokenOrTextData(m_DecodeState, initTokenOrDataLength: true, out processed);
					m_DecodeState.SetDecodeState(DecodeStates.ElementDataStartPartial, resetOldMasks: false);
					result = true;
					break;
				}
				case ObxmlOpcode.OpcodeIds.STRTSEC:
					m_DecodeState.DecodeStateMask = DecodeStates.SectionStart;
					if (ReadSectionHeader(opcode))
					{
						m_DecodeState.SectionHeaderFound = true;
					}
					result = true;
					break;
				case ObxmlOpcode.OpcodeIds.DOC:
					ReadDocHeader(opcode);
					if (DocHeader.XmlDecl)
					{
						m_DecodeState.m_CurrentInstruction.Append(DocHeader.GetHeaderString());
						m_DecodeState.m_CurrentInstruction.PreviousCharNewLine = true;
						processed = m_DecodeState.WriteTokenOrData(initTokenOrDataLength: true);
					}
					result = true;
					break;
				case ObxmlOpcode.OpcodeIds.ENDSEC:
					if (m_DecodeState.ProcessingTokenSet)
					{
						m_DecodeState.ProcessingTokenSet = false;
					}
					ProcessPendingBytesOrTokenData(m_DecodeState, initTokenOrDataLength: false, initCsxDataLength: false, out processed);
					m_DecodeState.Parent.SetDecodeComplete();
					result = true;
					break;
				case ObxmlOpcode.OpcodeIds.CDATA1:
				case ObxmlOpcode.OpcodeIds.CDATA2:
				case ObxmlOpcode.OpcodeIds.CDATA8:
				{
					ulong num6 = m_InstructionData[0];
					m_DecodeState.TryAppendingBeginTagClosure(null, checkForInitialNode: false, checkForNewNode: false);
					m_DecodeState.GetLastNodeState().PendingDataNode = true;
					m_DecodeState.m_CurrentInstruction.WriteCDATABlock(m_DecodeState, null, (int)num6);
					m_DecodeState.GetLastNodeState().ChildNodesCount++;
					break;
				}
				case ObxmlOpcode.OpcodeIds.PI1L1:
				case ObxmlOpcode.OpcodeIds.PI2L4:
				{
					ulong num8 = m_InstructionData[0];
					int num9 = (int)m_InstructionData[1];
					string target = DataStream.ReadUtf8String((ulong)num9);
					string value = DataStream.ReadUtf8String(num8 - (ulong)num9);
					m_DecodeState.GetLastNodeState().ChildNodesCount++;
					m_DecodeState.GetLastNodeState().PendingDataNode = true;
					ProcessInstruction(target, value);
					break;
				}
				case ObxmlOpcode.OpcodeIds.TEXT1:
				case ObxmlOpcode.OpcodeIds.TEXT2:
				case ObxmlOpcode.OpcodeIds.TEXT8:
				{
					m_DecodeState.CurrentDataOperation = DataOperationTypes.LengthAndData;
					string text = ReadEventText(GetLastNodeState(), opcode);
					text = ((1 != (ObxmlDecodeContext.m_XMLTypeOptimizationLevel & 1)) ? text.ReplaceXmlChars() : text);
					m_DecodeState.GetLastNodeState().PendingDataNode = true;
					m_DecodeState.TryAppendingBeginTagClosure(null, checkForInitialNode: false, checkForNewNode: false);
					m_DecodeState.m_CurrentInstruction.Append(text);
					m_DecodeState.GetLastNodeState().ChildNodesCount++;
					break;
				}
				case ObxmlOpcode.OpcodeIds.CMT1:
				case ObxmlOpcode.OpcodeIds.CMT2:
				case ObxmlOpcode.OpcodeIds.CMT8:
				{
					if (m_DecodeState.m_IsProcessingDTD)
					{
						m_DecodeState.DTDInfo.InilializeSubset();
					}
					ulong num5 = m_InstructionData[0];
					m_DecodeState.TryAppendingBeginTagClosure(null, checkForInitialNode: false, checkForNewNode: false);
					ObxmlNodeState lastNodeState = m_DecodeState.GetLastNodeState();
					if (lastNodeState != null && (lastNodeState.m_ParentNode == null || (lastNodeState.m_ParentNode != null && !m_DecodeState.PerformFullXmlParse)))
					{
						m_DecodeState.m_CurrentInstruction.AppendWhiteSpaces(m_DecodeState, lastNodeState, appendEndOfLine: false, prefixEndOfLine: true);
					}
					m_DecodeState.m_CurrentInstruction.AppendComment(null, (int)num5);
					if (lastNodeState != null)
					{
						lastNodeState.ChildNodesCount++;
					}
					break;
				}
				case ObxmlOpcode.OpcodeIds.DTDSTR:
				{
					int num2 = ReadNum2();
					m_DecodeState.DTDInfo.ObjectName = ((num2 > 0) ? DataStream.ReadUtf8String((ulong)num2) : null);
					num2 = ReadNum2();
					m_DecodeState.DTDInfo.PublicId = ((num2 > 0) ? DataStream.ReadUtf8String((ulong)num2) : null);
					num2 = ReadNum2();
					m_DecodeState.DTDInfo.SystemId = ((num2 > 0) ? DataStream.ReadUtf8String((ulong)num2) : null);
					string.IsNullOrEmpty(m_DecodeState.DTDInfo.SystemId);
					m_DecodeState.DTDInfo.StartDTD();
					break;
				}
				case ObxmlOpcode.OpcodeIds.DTDELEM:
				{
					int num10 = ReadNum2();
					DTDElementInfo dTDElementInfo = new DTDElementInfo();
					dTDElementInfo.ElementName = ((num10 > 0) ? DataStream.ReadUtf8String((ulong)num10) : null);
					num10 = ReadNum2();
					dTDElementInfo.ContentSpec = ((num10 > 0) ? DataStream.ReadUtf8String((ulong)num10) : null);
					m_DecodeState.DTDInfo.m_ElementList.Add(dTDElementInfo);
					m_DecodeState.DTDInfo.ElementDecl(dTDElementInfo);
					break;
				}
				case ObxmlOpcode.OpcodeIds.DTDALIST:
				{
					int num3 = ReadNum2();
					DTDElementAttributeInfo dTDElementAttributeInfo = new DTDElementAttributeInfo();
					dTDElementAttributeInfo.ElementName = ((num3 > 0) ? DataStream.ReadUtf8String((ulong)num3) : null);
					num3 = ReadNum2();
					dTDElementAttributeInfo.AttributeName = ((num3 > 0) ? DataStream.ReadUtf8String((ulong)num3) : null);
					num3 = ReadNum2();
					dTDElementAttributeInfo.AttributeType = ((num3 > 0) ? DataStream.ReadUtf8String((ulong)num3) : null);
					m_DecodeState.DTDInfo.AttributeDecl(dTDElementAttributeInfo);
					break;
				}
				case ObxmlOpcode.OpcodeIds.DTDENT:
				{
					int num7 = ReadNum2();
					DTDObject dTDObject3 = new DTDObject(DTDObjectTypes.Entity, (num7 > 0) ? DataStream.ReadUtf8String((ulong)num7) : null);
					num7 = ReadNum2();
					dTDObject3.ObjectValue = ((num7 > 0) ? DataStream.ReadUtf8String((ulong)num7) : null);
					num7 = ReadNum2();
					dTDObject3.PublicId = ((num7 > 0) ? DataStream.ReadUtf8String((ulong)num7) : null);
					num7 = ReadNum2();
					dTDObject3.SystemId = ((num7 > 0) ? DataStream.ReadUtf8String((ulong)num7) : null);
					num7 = ReadNum2();
					dTDObject3.Note = ((num7 > 0) ? DataStream.ReadUtf8String((ulong)num7) : null);
					m_DecodeState.DTDInfo.m_ObjectList.Add(dTDObject3);
					m_DecodeState.DTDInfo.EntityDecl(dTDObject3);
					break;
				}
				case ObxmlOpcode.OpcodeIds.DTDPENT:
				{
					int num11 = ReadNum2();
					DTDObject dTDObject4 = new DTDObject(DTDObjectTypes.PartialEntity, (num11 > 0) ? DataStream.ReadUtf8String((ulong)num11) : null);
					num11 = ReadNum2();
					dTDObject4.PublicId = ((num11 > 0) ? DataStream.ReadUtf8String((ulong)num11) : null);
					num11 = ReadNum2();
					dTDObject4.SystemId = ((num11 > 0) ? DataStream.ReadUtf8String((ulong)num11) : null);
					m_DecodeState.DTDInfo.m_ObjectList.Add(dTDObject4);
					m_DecodeState.DTDInfo.EntityDecl(dTDObject4);
					break;
				}
				case ObxmlOpcode.OpcodeIds.DTDNOT:
				{
					int num4 = ReadNum2();
					DTDObject dTDObject2 = new DTDObject(DTDObjectTypes.Note, (num4 > 0) ? DataStream.ReadUtf8String((ulong)num4) : null);
					num4 = ReadNum2();
					dTDObject2.PublicId = ((num4 > 0) ? DataStream.ReadUtf8String((ulong)num4) : null);
					num4 = ReadNum2();
					dTDObject2.SystemId = ((num4 > 0) ? DataStream.ReadUtf8String((ulong)num4) : null);
					m_DecodeState.DTDInfo.m_ObjectList.Add(dTDObject2);
					m_DecodeState.DTDInfo.NotationDecl(dTDObject2);
					break;
				}
				case ObxmlOpcode.OpcodeIds.DTDEND:
					m_DecodeState.DTDInfo.EndDTD();
					break;
				case ObxmlOpcode.OpcodeIds.ENTREF:
				{
					int num = ReadNum1();
					DTDObject dTDObject = new DTDObject(DTDObjectTypes.Entity, (num > 0) ? DataStream.ReadUtf8String((ulong)num) : null);
					m_DecodeState.DTDInfo.m_ObjectList.Add(dTDObject);
					m_DecodeState.DTDInfo.EntityReference(dTDObject);
					break;
				}
				case ObxmlOpcode.OpcodeIds.CHARREF:
					result = true;
					break;
				default:
					result = false;
					break;
				case ObxmlOpcode.OpcodeIds.CHUNK:
					break;
				}
			}
			if (m_DecodeState.IsExtendedOpcode)
			{
				switch (opcode)
				{
				case ObxmlOpcode.OpcodeIds.DATSTR2:
				{
					int num16 = ReadNum2();
					DTDObject dTDObject7 = new DTDObject(DTDObjectTypes.Note, (num16 > 0) ? DataStream.ReadUtf8String((ulong)num16) : null);
					num16 = ReadNum2();
					dTDObject7.PublicId = ((num16 > 0) ? DataStream.ReadUtf8String((ulong)num16) : null);
					num16 = ReadNum2();
					dTDObject7.SystemId = ((num16 > 0) ? DataStream.ReadUtf8String((ulong)num16) : null);
					m_DecodeState.DTDInfo.m_ObjectList.Add(dTDObject7);
					num16 = ReadNum1();
					if (num16 == ObxmlOpcode.DTD_SYSTEM_EMPTY)
					{
						dTDObject7.SystemId = "";
					}
					else if (num16 == ObxmlOpcode.DTD_internal_EMPTY)
					{
						dTDObject7.PublicId = "";
					}
					else if (num16 == ObxmlOpcode.DTD_internal_SYSTEM_EMPTY)
					{
						dTDObject7.SystemId = "";
						dTDObject7.PublicId = "";
					}
					m_DecodeState.DTDInfo.m_ObjectList.Add(dTDObject7);
					m_DecodeState.IsExtendedOpcode = false;
					m_DecodeState.DTDInfo.NotationDecl(dTDObject7);
					break;
				}
				case ObxmlOpcode.OpcodeIds.DATSTR1:
				{
					int num17 = ReadNum2();
					m_DecodeState.DTDInfo.ObjectName = ((num17 > 0) ? DataStream.ReadUtf8String((ulong)num17) : null);
					num17 = ReadNum2();
					m_DecodeState.DTDInfo.PublicId = ((num17 > 0) ? DataStream.ReadUtf8String((ulong)num17) : null);
					num17 = ReadNum2();
					m_DecodeState.DTDInfo.SystemId = ((num17 > 0) ? DataStream.ReadUtf8String((ulong)num17) : null);
					num17 = ReadNum1();
					if (num17 == ObxmlOpcode.DTD_SYSTEM_EMPTY)
					{
						m_DecodeState.DTDInfo.SystemId = "";
					}
					else if (num17 == ObxmlOpcode.DTD_internal_EMPTY)
					{
						m_DecodeState.DTDInfo.PublicId = "";
					}
					else if (num17 == ObxmlOpcode.DTD_internal_SYSTEM_EMPTY)
					{
						m_DecodeState.DTDInfo.SystemId = "";
						m_DecodeState.DTDInfo.PublicId = "";
					}
					m_DecodeState.IsExtendedOpcode = false;
					m_DecodeState.DTDInfo.StartDTD();
					break;
				}
				case ObxmlOpcode.OpcodeIds.DATSTR3:
				{
					int num15 = ReadNum2();
					DTDObject dTDObject6 = new DTDObject(DTDObjectTypes.Entity, (num15 > 0) ? DataStream.ReadUtf8String((ulong)num15) : null);
					num15 = ReadNum2();
					dTDObject6.ObjectValue = ((num15 > 0) ? DataStream.ReadUtf8String((ulong)num15) : null);
					num15 = ReadNum2();
					dTDObject6.PublicId = ((num15 > 0) ? DataStream.ReadUtf8String((ulong)num15) : null);
					num15 = ReadNum2();
					dTDObject6.SystemId = ((num15 > 0) ? DataStream.ReadUtf8String((ulong)num15) : null);
					num15 = ReadNum2();
					dTDObject6.Note = ((num15 > 0) ? DataStream.ReadUtf8String((ulong)num15) : null);
					m_DecodeState.DTDInfo.m_ObjectList.Add(dTDObject6);
					num15 = ReadNum1();
					if (num15 == ObxmlOpcode.DTD_SYSTEM_EMPTY)
					{
						dTDObject6.SystemId = "";
					}
					else if (num15 == ObxmlOpcode.DTD_internal_EMPTY)
					{
						dTDObject6.PublicId = "";
					}
					else if (num15 == ObxmlOpcode.DTD_internal_SYSTEM_EMPTY)
					{
						dTDObject6.SystemId = "";
						dTDObject6.PublicId = "";
					}
					m_DecodeState.DTDInfo.m_ObjectList.Add(dTDObject6);
					m_DecodeState.IsExtendedOpcode = false;
					m_DecodeState.DTDInfo.EntityDecl(dTDObject6);
					break;
				}
				case ObxmlOpcode.OpcodeIds.DATSTR4:
				{
					int num14 = ReadNum2();
					DTDObject dTDObject5 = new DTDObject(DTDObjectTypes.PartialEntity, (num14 > 0) ? DataStream.ReadUtf8String((ulong)num14) : null);
					num14 = ReadNum2();
					dTDObject5.ObjectValue = ((num14 > 0) ? DataStream.ReadUtf8String((ulong)num14) : null);
					num14 = ReadNum2();
					dTDObject5.PublicId = ((num14 > 0) ? DataStream.ReadUtf8String((ulong)num14) : null);
					num14 = ReadNum2();
					dTDObject5.SystemId = ((num14 > 0) ? DataStream.ReadUtf8String((ulong)num14) : null);
					if (dTDObject5.ObjectName != null && dTDObject5.ObjectName.Length != 0)
					{
						dTDObject5.ObjectName = ObxmlInstructionState.sXmlPercentage + dTDObject5.ObjectName;
					}
					num14 = ReadNum1();
					if (num14 == ObxmlOpcode.DTD_SYSTEM_EMPTY)
					{
						dTDObject5.SystemId = "";
					}
					else if (num14 == ObxmlOpcode.DTD_internal_EMPTY)
					{
						dTDObject5.PublicId = "";
					}
					else if (num14 == ObxmlOpcode.DTD_internal_SYSTEM_EMPTY)
					{
						dTDObject5.SystemId = "";
						dTDObject5.PublicId = "";
					}
					m_DecodeState.DTDInfo.m_ObjectList.Add(dTDObject5);
					m_DecodeState.IsExtendedOpcode = false;
					m_DecodeState.DTDInfo.EntityDecl(dTDObject5);
					break;
				}
				case ObxmlOpcode.OpcodeIds.DATSTR5:
				{
					int num12 = ReadNum2();
					string elementName = ((num12 > 0) ? DataStream.ReadUtf8String((ulong)num12) : null);
					int num13 = ReadNum2();
					for (int i = 0; i < num13; i++)
					{
						DTDElementAttributeInfo dTDElementAttributeInfo2 = new DTDElementAttributeInfo();
						dTDElementAttributeInfo2.ElementName = elementName;
						num12 = ReadNum2();
						dTDElementAttributeInfo2.AttributeName = ((num12 > 0) ? DataStream.ReadUtf8String((ulong)num12) : null);
						num12 = ReadNum2();
						dTDElementAttributeInfo2.AttributeType = ((num12 > 0) ? DataStream.ReadUtf8String((ulong)num12) : null);
						dTDElementAttributeInfo2.SplitAttrString(dTDElementAttributeInfo2.AttributeType);
						m_DecodeState.DTDInfo.AttributeDecl(dTDElementAttributeInfo2);
					}
					if (ReadNum1() != 0)
					{
						throw new OracleException(ResourceStringConstants.XML_TYPE_BINARY_INTERNAL_ERROR, string.Empty, string.Empty, ObxmlDecodeResponse.GetErrorMessage(ObxmlErrorTypes.StringNotTerminated));
					}
					if (m_DecodeState.DTDInfo.m_AttributeList != null)
					{
						m_DecodeState.DTDInfo.m_AttributeList.Clear();
					}
					m_DecodeState.IsExtendedOpcode = false;
					break;
				}
				default:
					throw new OracleException(ResourceStringConstants.XML_TYPE_BINARY_INTERNAL_ERROR, string.Empty, string.Empty, ObxmlDecodeResponse.GetErrorMessage(ObxmlErrorTypes.CsxInvalidOpcode));
				}
			}
			switch (opcode)
			{
			case ObxmlOpcode.OpcodeIds.PRPSTK1:
			case ObxmlOpcode.OpcodeIds.PRPSTK2:
			case ObxmlOpcode.OpcodeIds.PRPSTT2:
			case ObxmlOpcode.OpcodeIds.PRPSTT4:
			case ObxmlOpcode.OpcodeIds.PRPSTT8:
			case ObxmlOpcode.OpcodeIds.PRPSTK1F:
			case ObxmlOpcode.OpcodeIds.PRPSTK2F:
			case ObxmlOpcode.OpcodeIds.PRPSTT2F:
			case ObxmlOpcode.OpcodeIds.PRPSTT4F:
			case ObxmlOpcode.OpcodeIds.PRPSTT8F:
			case ObxmlOpcode.OpcodeIds.PRPSTK1V:
			case ObxmlOpcode.OpcodeIds.PRPSTK2V:
			case ObxmlOpcode.OpcodeIds.PRPSTT2V:
			case ObxmlOpcode.OpcodeIds.PRPSTT4V:
			case ObxmlOpcode.OpcodeIds.PRPSTT8V:
				m_DecodeState.SetDecodeState(DecodeStates.ElementStart);
				ReadElementInfo(opcode, optimizedOpcode: false);
				ProcessTokenOrTextData(m_DecodeState, initTokenOrDataLength: true, out processed);
				break;
			case ObxmlOpcode.OpcodeIds.PRPK1L1:
			case ObxmlOpcode.OpcodeIds.PRPK1L2:
			case ObxmlOpcode.OpcodeIds.PRPK2L1:
			case ObxmlOpcode.OpcodeIds.PRPK2L2:
			case ObxmlOpcode.OpcodeIds.PRPT2L1:
			case ObxmlOpcode.OpcodeIds.PRPT2L2:
			case ObxmlOpcode.OpcodeIds.PRPT4L1:
			case ObxmlOpcode.OpcodeIds.PRPT4L2:
			case ObxmlOpcode.OpcodeIds.PRPT8L1:
			case ObxmlOpcode.OpcodeIds.PRPT8L2:
			{
				m_DecodeState.SetDecodeState(DecodeStates.ElementStart | DecodeStates.ElementEndPending | DecodeStates.ElementDataStartElementOpt);
				ObxmlNodeState obxmlNodeState = ReadElementInfo(opcode, optimizedOpcode: true);
				if (ProcessTokenOrTextData(m_DecodeState, initTokenOrDataLength: true, out processed) > 0)
				{
					if (obxmlNodeState.NodeDataLen != 0 && m_DecodeState.m_CurrentInstruction.m_CsxDataLength > 0)
					{
						m_DecodeState.m_CurrentInstruction.AppendElementStartTagClosing(m_DecodeState, bPreviousElement: false);
						obxmlNodeState.ChildNodesCount++;
						ProcessPendingBytesOrTokenData(m_DecodeState, initTokenOrDataLength: true, initCsxDataLength: false, out processed);
						_ = 0;
					}
					if (ProcessEndElement(out processed) > 0)
					{
						m_DecodeState.ResetDecodeStateMask(DecodeStates.ElementEndStart | DecodeStates.ElementEndPending | DecodeStates.ElementDataStartElementOpt);
					}
				}
				break;
			}
			case ObxmlOpcode.OpcodeIds.DEFQ4N4L1:
			case ObxmlOpcode.OpcodeIds.DEFQ4N4L2:
			case ObxmlOpcode.OpcodeIds.DEFQ4N8L1:
			case ObxmlOpcode.OpcodeIds.DEFQ4N8L2:
			case ObxmlOpcode.OpcodeIds.DEFQ8N4L1:
			case ObxmlOpcode.OpcodeIds.DEFQ8N4L2:
			case ObxmlOpcode.OpcodeIds.DEFQ8N8L1:
			case ObxmlOpcode.OpcodeIds.DEFQ8N8L2:
			{
				ObxmlToken token = null;
				ReadToken(opcode, out token);
				result = true;
				break;
			}
			case ObxmlOpcode.OpcodeIds.DEFNM4L1:
			case ObxmlOpcode.OpcodeIds.DEFNM4L2:
			case ObxmlOpcode.OpcodeIds.DEFNM8L1:
			case ObxmlOpcode.OpcodeIds.DEFNM8L2:
				ReadNamespaceToken(opcode);
				result = true;
				break;
			case ObxmlOpcode.OpcodeIds.DEFPFX4:
			case ObxmlOpcode.OpcodeIds.DEFPFX8:
			{
				PrefixInfo prefixInfo = null;
				result = ReadPrefix(opcode, out prefixInfo);
				break;
			}
			case ObxmlOpcode.OpcodeIds.SPACE1:
			case ObxmlOpcode.OpcodeIds.SPACE2:
			{
				char[] array = null;
				int datalen = 0;
				array = DecodeWhitespaces(opcode, out datalen);
				m_DecodeState.TryAppendingBeginTagClosure(null, checkForInitialNode: false, checkForNewNode: false);
				m_DecodeState.m_CurrentInstruction.Append(array, 0, datalen);
				break;
			}
			case ObxmlOpcode.OpcodeIds.SPACE8:
				SkipData(opcode);
				break;
			case ObxmlOpcode.OpcodeIds.ENDPRP:
				m_DecodeState.SetDecodeState(DecodeStates.ElementEndStart);
				ProcessEndElement(out processed);
				break;
			case ObxmlOpcode.OpcodeIds.ENDPRPSP:
			case ObxmlOpcode.OpcodeIds.ENDPRPSP8:
				m_DecodeState.SetDecodeState(DecodeStates.ElementEndStart);
				ProcessEndElement(out processed);
				break;
			case ObxmlOpcode.OpcodeIds.ELMSTART:
			case ObxmlOpcode.OpcodeIds.ELMSTSSEQ:
			{
				ObxmlNodeState lastNodeState2 = GetLastNodeState();
				ObxmlNodeState ns = null;
				if (lastNodeState2.IsArrayMode)
				{
					ns = m_DecodeState.GetCurrentNodeState(clone: true);
				}
				else
				{
					if (!lastNodeState2.IsSequentialMode)
					{
						throw new OracleException(ResourceStringConstants.XML_TYPE_BINARY_INTERNAL_ERROR, string.Empty, string.Empty, ObxmlDecodeResponse.GetErrorMessage(ObxmlErrorTypes.CsxInvalidInstruction));
					}
					lastNodeState2.ArrayModeCount++;
				}
				ReadElementInfo(opcode, optimizedOpcode: false, ns);
				break;
			}
			case ObxmlOpcode.OpcodeIds.ARRBEG:
			case ObxmlOpcode.OpcodeIds.ARREND:
				GetLastNodeState().SetArrayMode(opcode == ObxmlOpcode.OpcodeIds.ARRBEG);
				break;
			}
			return result;
		}

		private bool HandleArrayModeDataBegin(ObxmlOpcode.OpcodeIds opcode, out long processed)
		{
			ObxmlNodeState lastNodeState = GetLastNodeState();
			ObxmlNodeState obxmlNodeState = null;
			processed = 0L;
			if (lastNodeState.IsArrayMode)
			{
				obxmlNodeState = m_DecodeState.GetCurrentNodeState(clone: true);
			}
			else
			{
				if (!lastNodeState.IsSequentialMode)
				{
					return false;
				}
				lastNodeState.ArrayModeCount++;
			}
			ReadElementInfo(opcode, optimizedOpcode: false, obxmlNodeState, arrayModeDataBegin: true);
			if (obxmlNodeState == null)
			{
				throw new OracleException(ResourceStringConstants.XML_TYPE_BINARY_INTERNAL_ERROR, string.Empty, string.Empty, ObxmlDecodeResponse.GetErrorMessage(ObxmlErrorTypes.CsxInvalidInstruction));
			}
			obxmlNodeState.ChildNodesCount++;
			m_DecodeState.TryAppendingBeginTagClosure(obxmlNodeState, checkForInitialNode: false, checkForNewNode: false);
			ProcessTokenOrTextData(m_DecodeState, initTokenOrDataLength: true, out processed);
			return true;
		}

		private void ReadAttributes_New(bool skip = false)
		{
			m_DecodeState.AttributeList.Clear();
			ObxmlNodeState obxmlNodeState = GetLastNodeState();
			short num = 0;
			m_DecodeState.SetDecodeState(DecodeStates.ElementStartAttributeStart);
			while (true)
			{
				ObxmlOpcode.OpcodeIds opcodeIds = ReadInstructionInfo(readNewOpcode: true);
				InstructionPending = true;
				if (opcodeIds == ObxmlOpcode.OpcodeIds.None)
				{
					throw new OracleException(ResourceStringConstants.XML_TYPE_BINARY_INTERNAL_ERROR, string.Empty, string.Empty, ObxmlDecodeResponse.GetErrorMessage(ObxmlErrorTypes.CsxInvalidOpcode));
				}
				if ((short)opcodeIds == ObxmlInstructionFormat.NOOP)
				{
					throw new OracleException(ResourceStringConstants.XML_TYPE_BINARY_INTERNAL_ERROR, string.Empty, string.Empty, ObxmlDecodeResponse.GetErrorMessage(ObxmlErrorTypes.CsxInvalidOpcode));
				}
				switch (opcodeIds)
				{
				case ObxmlOpcode.OpcodeIds.CHUNK:
				case ObxmlOpcode.OpcodeIds.NOSEQ:
				case ObxmlOpcode.OpcodeIds.NOP:
				case ObxmlOpcode.OpcodeIds.NOPARR:
					break;
				default:
					return;
				case ObxmlOpcode.OpcodeIds.PRPSTK1:
				case ObxmlOpcode.OpcodeIds.PRPSTK2:
				case ObxmlOpcode.OpcodeIds.PRPSTT2:
				case ObxmlOpcode.OpcodeIds.PRPSTT4:
				case ObxmlOpcode.OpcodeIds.PRPSTT8:
				case ObxmlOpcode.OpcodeIds.PRPSTK1F:
				case ObxmlOpcode.OpcodeIds.PRPSTK2F:
				case ObxmlOpcode.OpcodeIds.PRPSTT2F:
				case ObxmlOpcode.OpcodeIds.PRPSTT4F:
				case ObxmlOpcode.OpcodeIds.PRPSTT8F:
				case ObxmlOpcode.OpcodeIds.PRPSTK1V:
				case ObxmlOpcode.OpcodeIds.PRPSTK2V:
				case ObxmlOpcode.OpcodeIds.PRPSTT2V:
				case ObxmlOpcode.OpcodeIds.PRPSTT4V:
				case ObxmlOpcode.OpcodeIds.PRPSTT8V:
				case ObxmlOpcode.OpcodeIds.ARRSTK1V:
				case ObxmlOpcode.OpcodeIds.ARRSTK2V:
				case ObxmlOpcode.OpcodeIds.ARRSTT4V:
				case ObxmlOpcode.OpcodeIds.ARRSTT8V:
				{
					bool flag = false;
					string text = null;
					byte b;
					if (opcodeIds >= ObxmlOpcode.OpcodeIds.PRPSTK1F && opcodeIds <= ObxmlOpcode.OpcodeIds.PRPSTT8F)
					{
						b = (byte)m_InstructionData[1];
					}
					else if ((opcodeIds >= ObxmlOpcode.OpcodeIds.PRPSTK1V && opcodeIds <= ObxmlOpcode.OpcodeIds.PRPSTT8V) || (opcodeIds >= ObxmlOpcode.OpcodeIds.ARRSTK1V && opcodeIds <= ObxmlOpcode.OpcodeIds.ARRSTT8V))
					{
						b = (byte)m_InstructionData[2];
						flag = true;
					}
					else
					{
						b = 0;
					}
					if ((m_InstructionFormat.flags & ObxmlInstructionFormat.KIDNUM) <= 0)
					{
						ulong tokenId = (flag ? m_InstructionData[1] : m_InstructionData[0]);
						obxmlNodeState = GetNodeData(tokenId, NodeTypes.None, 0uL);
					}
					if (!obxmlNodeState.IsAttribute)
					{
						return;
					}
					if (flag)
					{
						if ((b & ObxmlInstructionFormat.ELSTF_NOTDECTYP) > 0)
						{
							DataStream.ReadInt4();
						}
						if ((b & ObxmlInstructionFormat.ELSTF_PFXID) > 0)
						{
							num = DataStream.ReadShortInt();
							text = m_DecodeState.GetPrefixInfo((ulong)num).Prefix;
						}
					}
					text = obxmlNodeState.SetPrefix(m_DecodeState, text);
					string @namespace = "";
					while (true)
					{
						opcodeIds = ReadInstructionInfo(readNewOpcode: true);
						if (opcodeIds == ObxmlOpcode.OpcodeIds.ENDPRP)
						{
							break;
						}
						if (!m_InstructionFormat.hasfixeddata && opcodeIds != ObxmlOpcode.OpcodeIds.DATAL2 && opcodeIds != ObxmlOpcode.OpcodeIds.DATAL8)
						{
							throw new OracleException(ResourceStringConstants.XML_TYPE_BINARY_INTERNAL_ERROR, string.Empty, string.Empty, ObxmlDecodeResponse.GetErrorMessage(ObxmlErrorTypes.CsxInvalidOpcode));
						}
						ulong dataLen = GetDataLen((short)opcodeIds);
						if (!skip)
						{
							@namespace = DataStream.ReadUtf8String(dataLen);
						}
						else
						{
							SkipBytes((long)dataLen);
						}
					}
					m_DecodeState.SetDecodeState(DecodeStates.ElementStartAttributeDone);
					if (!skip)
					{
						if (text == null || text.Length == 0)
						{
							AttributeInfo attributeInfo = m_DecodeState.GetAttributeInfo();
							attributeInfo.ResetAttributeInfo(m_DecodeState, obxmlNodeState, isNamespaceAttribute: false, text, obxmlNodeState.m_ElementToken.TokenName, m_DecodeState.GetNamespaceUriForNode(obxmlNodeState), @namespace);
							obxmlNodeState.AddAttributeInfo(m_DecodeState, attributeInfo);
						}
						else
						{
							new PrefixInfo(m_DecodeState.Parent.DecodeContext, 0, text, obxmlNodeState.m_ElementToken.NamespaceId);
							obxmlNodeState.AddAttributeInfo(m_DecodeState, m_DecodeState.GetAttributeInfo().ResetAttributeInfo(m_DecodeState, obxmlNodeState, isNamespaceAttribute: false, text, obxmlNodeState.m_ElementToken.TokenName, m_DecodeState.GetNamespaceUriForNode(obxmlNodeState), @namespace));
						}
					}
					break;
				}
				case ObxmlOpcode.OpcodeIds.PRPK1L1:
				case ObxmlOpcode.OpcodeIds.PRPK1L2:
				case ObxmlOpcode.OpcodeIds.PRPK2L1:
				case ObxmlOpcode.OpcodeIds.PRPK2L2:
				case ObxmlOpcode.OpcodeIds.PRPT2L1:
				case ObxmlOpcode.OpcodeIds.PRPT2L2:
				case ObxmlOpcode.OpcodeIds.PRPT4L1:
				case ObxmlOpcode.OpcodeIds.PRPT4L2:
				case ObxmlOpcode.OpcodeIds.PRPT8L1:
				case ObxmlOpcode.OpcodeIds.PRPT8L2:
				{
					string text = null;
					if ((m_InstructionFormat.flags & ObxmlInstructionFormat.KIDNUM) <= 0)
					{
						obxmlNodeState = GetNodeData(m_InstructionData[1], NodeTypes.None, 0uL);
					}
					if (!obxmlNodeState.IsAttribute)
					{
						m_DecodeState.SetDecodeState(DecodeStates.ElementStartAttributeDone);
						return;
					}
					m_DecodeState.CurrentDataOperation = DataOperationTypes.LengthAndData;
					if (!skip)
					{
						string @namespace = ReadEventText(null, opcodeIds);
						text = obxmlNodeState.SetPrefix(m_DecodeState, null);
						if (string.IsNullOrEmpty(text))
						{
							obxmlNodeState.AddAttributeInfo(m_DecodeState, m_DecodeState.GetAttributeInfo().ResetAttributeInfo(m_DecodeState, obxmlNodeState, isNamespaceAttribute: false, text, obxmlNodeState.m_ElementToken.TokenName, m_DecodeState.GetNamespaceUriForNode(obxmlNodeState), @namespace));
						}
						else
						{
							obxmlNodeState.AddAttributeInfo(m_DecodeState, m_DecodeState.GetAttributeInfo().ResetAttributeInfo(m_DecodeState, obxmlNodeState, isNamespaceAttribute: false, text, obxmlNodeState.m_ElementToken.TokenName, m_DecodeState.GetNamespaceUriForNode(obxmlNodeState), @namespace));
						}
					}
					break;
				}
				case ObxmlOpcode.OpcodeIds.NMSPC:
				{
					num = (short)m_InstructionData[0];
					PrefixInfo prefixInfo2 = m_DecodeState.GetPrefixInfo((ulong)num);
					m_DecodeState.PushNamespace(prefixInfo2);
					if (!skip)
					{
						if (prefixInfo2.Prefix == null || prefixInfo2.Prefix.Length == 0)
						{
							obxmlNodeState.AddAttributeInfo(m_DecodeState, m_DecodeState.GetAttributeInfo().ResetAttributeInfo(m_DecodeState, obxmlNodeState, isNamespaceAttribute: true, "xmlns", prefixInfo2.Prefix, ObxmlDecoder.nameXMLNSNamespace, prefixInfo2.Uri));
						}
						else
						{
							obxmlNodeState.AddAttributeInfo(m_DecodeState, m_DecodeState.GetAttributeInfo().ResetAttributeInfo(m_DecodeState, obxmlNodeState, isNamespaceAttribute: true, "xmlns", prefixInfo2.Prefix, ObxmlDecoder.nameXMLNSNamespace, prefixInfo2.Uri));
						}
					}
					break;
				}
				case ObxmlOpcode.OpcodeIds.NSP4:
				case ObxmlOpcode.OpcodeIds.NSP8:
				{
					ulong dataLen = GetDataLen((short)opcodeIds);
					string text = DataStream.ReadUtf8String(dataLen);
					ulong nsid = m_InstructionData[1];
					string @namespace = m_DecodeState.GetNamespace(nsid);
					PrefixInfo pInfo = m_DecodeState.SetPrefix(0, text, nsid);
					m_DecodeState.PushNamespace(pInfo);
					if (!skip)
					{
						if (text == null || text.Length == 0)
						{
							obxmlNodeState.AddAttributeInfo(m_DecodeState, m_DecodeState.GetAttributeInfo().ResetAttributeInfo(m_DecodeState, obxmlNodeState, isNamespaceAttribute: true, text, "xmlns", ObxmlDecoder.nameXMLNSNamespace, @namespace));
						}
						else
						{
							obxmlNodeState.AddAttributeInfo(m_DecodeState, m_DecodeState.GetAttributeInfo().ResetAttributeInfo(m_DecodeState, obxmlNodeState, isNamespaceAttribute: true, text, "xmlns", ObxmlDecoder.nameXMLNSNamespace, @namespace));
						}
					}
					break;
				}
				case ObxmlOpcode.OpcodeIds.DEFNM4L1:
				case ObxmlOpcode.OpcodeIds.DEFNM4L2:
				case ObxmlOpcode.OpcodeIds.DEFNM8L1:
				case ObxmlOpcode.OpcodeIds.DEFNM8L2:
					ReadNamespaceToken(opcodeIds);
					break;
				case ObxmlOpcode.OpcodeIds.DEFQ4N4L1:
				case ObxmlOpcode.OpcodeIds.DEFQ4N4L2:
				case ObxmlOpcode.OpcodeIds.DEFQ4N8L1:
				case ObxmlOpcode.OpcodeIds.DEFQ4N8L2:
				case ObxmlOpcode.OpcodeIds.DEFQ8N4L1:
				case ObxmlOpcode.OpcodeIds.DEFQ8N4L2:
				case ObxmlOpcode.OpcodeIds.DEFQ8N8L1:
				case ObxmlOpcode.OpcodeIds.DEFQ8N8L2:
				{
					ObxmlToken token = null;
					ReadToken(opcodeIds, out token);
					break;
				}
				case ObxmlOpcode.OpcodeIds.DEFPFX4:
				case ObxmlOpcode.OpcodeIds.DEFPFX8:
				{
					PrefixInfo prefixInfo = null;
					ReadPrefix(opcodeIds, out prefixInfo);
					break;
				}
				case ObxmlOpcode.OpcodeIds.SPACEQN:
				case ObxmlOpcode.OpcodeIds.SPACEQN8:
					m_DecodeState.CurrentDataOperation = DataOperationTypes.DataOnly;
					SkipData(opcodeIds);
					break;
				case ObxmlOpcode.OpcodeIds.REF:
				case ObxmlOpcode.OpcodeIds.TEXT1:
				case ObxmlOpcode.OpcodeIds.TEXT2:
				case ObxmlOpcode.OpcodeIds.TEXT8:
				case ObxmlOpcode.OpcodeIds.CDATA1:
				case ObxmlOpcode.OpcodeIds.CDATA2:
				case ObxmlOpcode.OpcodeIds.CDATA8:
				case ObxmlOpcode.OpcodeIds.PI1L1:
				case ObxmlOpcode.OpcodeIds.PI2L4:
				case ObxmlOpcode.OpcodeIds.CMT1:
				case ObxmlOpcode.OpcodeIds.CMT2:
				case ObxmlOpcode.OpcodeIds.CMT8:
				case ObxmlOpcode.OpcodeIds.ELMSTART:
				case ObxmlOpcode.OpcodeIds.ELMSTSSEQ:
				case ObxmlOpcode.OpcodeIds.ARRBEG:
				case ObxmlOpcode.OpcodeIds.ARREND:
				case ObxmlOpcode.OpcodeIds.ENDPRP:
				case ObxmlOpcode.OpcodeIds.PRTDATA:
				case ObxmlOpcode.OpcodeIds.PRTDATAT:
				case ObxmlOpcode.OpcodeIds.PRTTEXT:
				case ObxmlOpcode.OpcodeIds.PRTCDATA:
				case ObxmlOpcode.OpcodeIds.PRTPI:
				case ObxmlOpcode.OpcodeIds.PRTCMT:
				case ObxmlOpcode.OpcodeIds.SPACE1:
				case ObxmlOpcode.OpcodeIds.SPACE2:
				case ObxmlOpcode.OpcodeIds.SPACE8:
				case ObxmlOpcode.OpcodeIds.XMLDECL:
					return;
				}
			}
		}

		internal bool ReadInlineToken(ObxmlOpcode.OpcodeIds opcode)
		{
			return true;
		}

		internal bool ReadNamespaceToken(ObxmlOpcode.OpcodeIds opcode)
		{
			ulong dataLen = GetDataLen((short)opcode);
			byte[] tokenNameBytes = DataStream.ReadBytes((int)dataLen);
			ulong num = m_InstructionData[1];
			ObxmlToken token = new ObxmlToken(num, num, tokenNameBytes, TokenTypes.NamespaceToken);
			m_DecodeState.SetToken(token);
			return true;
		}

		internal bool ReadPrefix(ObxmlOpcode.OpcodeIds opcode, out PrefixInfo prefixInfo)
		{
			ulong dataLen = GetDataLen((short)opcode);
			string prefix = DataStream.ReadUtf8String(dataLen);
			ulong num = m_InstructionData[2];
			ulong nsid = m_InstructionData[1];
			prefixInfo = new PrefixInfo(m_DecodeState.Parent.DecodeContext, (short)num, prefix, nsid, string.Empty);
			m_DecodeState.SetPrefix(prefixInfo);
			return true;
		}

		internal bool ReadToken(ObxmlOpcode.OpcodeIds opcode, out ObxmlToken token)
		{
			token = null;
			ulong dataLen = GetDataLen((short)opcode);
			byte[] tokenNameBytes = DataStream.ReadBytes((int)dataLen);
			ulong tokenId = m_InstructionData[2];
			ulong namespaceId = m_InstructionData[3];
			bool flag = ((int)m_InstructionData[1] & ObxmlInstructionFormat.CSX_DEFQNF_ATTR) > 0;
			token = new ObxmlToken(tokenId, namespaceId, tokenNameBytes, flag ? TokenTypes.AttributeToken : TokenTypes.ElementToken);
			m_DecodeState.SetToken(token);
			return true;
		}

		internal string ReadEventText(ObxmlNodeState elem, ObxmlOpcode.OpcodeIds opcode)
		{
			string text = null;
			ulong dataLen = GetDataLen((short)opcode);
			switch (m_DecodeState.m_CurrentInstruction.DataType)
			{
			case 1:
				text = DataStream.ReadUtf8String(dataLen);
				break;
			case 4:
			{
				long num = 0L;
				text = (dataLen switch
				{
					1uL => ReadNum1(), 
					2uL => ReadNum2(), 
					4uL => ReadNum4(), 
					8uL => DataStream.ReadInt8(), 
					_ => throw new OracleException(ResourceStringConstants.XML_TYPE_BINARY_INTERNAL_ERROR, string.Empty, string.Empty, ObxmlDecodeResponse.GetErrorMessage(ObxmlErrorTypes.CsxInvalidInstruction)), 
				}).ToString();
				break;
			}
			default:
				DataStream.ReadBytes((int)dataLen);
				text = null;
				break;
			}
			m_DecodeState.CurrentDataOperation = DataOperationTypes.NoData;
			return text;
		}

		private void ProcessInstruction(string target, string value)
		{
			try
			{
				m_DecodeState.TryAppendingBeginTagClosure(null, checkForInitialNode: false, checkForNewNode: false);
				m_DecodeState.m_CurrentInstruction.Append("<?");
				m_DecodeState.m_CurrentInstruction.Append(target + " " + value);
				m_DecodeState.m_CurrentInstruction.Append("?>");
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Private, (OracleTraceTag)285212672, OracleTraceClassName.ObxmlInstruction, OracleTraceFuncName.ProcessInstruction, ex);
				throw;
			}
		}
	}
}
